
//
//  TKYTreatHandelDetitleController.m
//  StationHouseHelper
//
//  Created by apple on 2018/7/6.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYTreatHandelDetitleController.h"
#import "TKYResponsibilityHandleController.h"
#import "TKYCheckHandleController.h"
#import "TKYMessageController.h"
#import "TKYProcessController.h"
@interface TKYTreatHandelDetitleController ()

@property (nonatomic, strong)NSString * str ;
@property (nonatomic, strong)UISegmentedControl *segment;
@property (nonatomic, strong)TKYMessageController *messageVC;
@property (nonatomic, strong)TKYProcessController *processVC;

@end

@implementation TKYTreatHandelDetitleController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置界面
    [self setupUI];
    // Do any additional setup after loading the view from its nib.
}

/**
 设置界面
 */
- (void)setupUI{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"安全问题";
    self.navigationController.navigationBar.barTintColor = KNavColor;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"处理" style:UIBarButtonItemStylePlain target:self action:@selector(handlerightBarButtonAction:)];
    self.str = @"验收人";
    [self.view addSubview:self.segment];
    
    self.messageVC = [TKYMessageController new];
    self.messageVC.view.frame = CGRectMake(0, self.segment.kx_bottom, kScreenWidth, kScreenHeight-self.segment.kx_height);
    self.processVC = [TKYProcessController new];
    self.processVC.view.frame = CGRectMake(0, self.segment.kx_bottom, kScreenWidth, kScreenHeight-self.segment.kx_height);
    [self.view addSubview:self.processVC.view];
    
}

#pragma mark --- 按钮的处理事件
- (void)handlerightBarButtonAction:(UIBarButtonItem *)barButtonItem{
    if ([self.str isEqualToString:@"责任人"]) {
        NSLog(@"责任人");
        TKYResponsibilityHandleController *responsibilityHandleVC = [TKYResponsibilityHandleController new];
        [self.navigationController pushViewController:responsibilityHandleVC animated:YES];
    }else{
        TKYCheckHandleController *checkHandleVC = [TKYCheckHandleController new];
        [self.navigationController pushViewController:checkHandleVC animated:YES];
        NSLog(@"验收人");
    }
}

- (UISegmentedControl *)segment{
    if (_segment == nil) {
        _segment = [[UISegmentedControl alloc] initWithItems:@[@"信息",@"流程"]];
        _segment.frame = CGRectMake(kScreenWidth/2 - kHeightScale *50, MyNavBarHeight +kHeightScale *10, kWidthScale *100,  kHeightScale *30);
        _segment.tintColor = KNavColor;
        _segment.selectedSegmentIndex = 1;
        [_segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    }
    return _segment;
}

- (void)segmentAction:(UISegmentedControl *)segment {
    
    int index = (int)segment.selectedSegmentIndex;
    switch (index) {
        case 0:
            [self.view addSubview:self.messageVC.view];
            [self.processVC.view removeFromSuperview];
            break;
        case 1:
            [self.view addSubview:self.processVC.view];
            [self.messageVC.view removeFromSuperview];
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
